package com.vids.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 *  Swagger2 配置类
 * @author ly
 */
@EnableSwagger2WebMvc
@Configuration

public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.vids.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //标题
                .title("视图库")
                //描述
                .description("视图库 Restful-API-Doc")
                //这里配置的是服务网站
                .termsOfServiceUrl("")
                // 三个参数依次是姓名，个人网站，邮箱
                .contact(new Contact("视频图像数据库", "", ""))
                //版本
                .version("1.0")
                .build();
    }


}
